#include <cstdarg>
#include "VertexDeclaration.h"

VertexDeclaration::VertexDeclaration( int parameters, ... )
{
	va_list arguments;
	int sum = 0;

	va_start(arguments, parameters);
	for (int x = 0; x < parameters; x++)
	{
		m_parameters.push_back( va_arg(arguments, VertexType) );
		sum += m_parameters[x].m_size * (m_parameters[x].m_parameter == enumColor ? sizeof(unsigned char) : sizeof(float));
	}
	m_vertexSize = sum;
	va_end( arguments );
}

VertexDeclaration::VertexDeclaration( VertexType::Vector_t& parameters ) : m_parameters(parameters), m_vertexSize(0)
{
	for (VertexType::Vector_t::iterator it = parameters.begin(), end = parameters.end(); it != end; ++it)
	{
		m_vertexSize += it->m_size * (it->m_parameter == enumColor ? sizeof(unsigned char) : sizeof (float));
	}
}